<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">
dt {
  font-style: italic;
  margin-top: 15px;
  margin-bottom: 3px;
  margin-left: 0px;
  border-bottom: 1px dotted black;
}
dd {
  margin-left: 10px;
}
table {
  border-collapse:collapse;
  border: 1px solid black;
  margin-top: 7px;
}
th {
  border: 1px solid black;
  padding: 3 7 3 7;
}
td {
  border: 1px solid black;
  padding: 3 7 3 7;
}
</style></head><body><p><a name="invokestatic"></a><b>invokestatic</b> :
  invoke a class (static) method : <a href="opcodes.html">index</a> : <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitMethodInsn(int,%20java.lang.String,%20java.lang.String,%20java.lang.String)">visitMethodInsn()</a></p><dl><dt>Description</dt><dd>invokestatic calls a static method (also known as a class
method). For example, if you write in Java:<br></br><pre>
    System.exit(1);
</pre>
this
is compiled into the JVM code:<br></br><pre>
    iconst_1      ; push 1 onto the stack.
                  ; now call System.exit()
    invokestatic java/lang/System/exit(I)V
</pre>
Before
performing the method invokation, the class and the method identified by
&lt;method-spec&gt; are resolved. See Chapter 9 for a description of how
methods are resolved.<br></br>invokestatic looks at the <i xmlns="">descriptor</i> given in
&lt;method-spec&gt;, and determines how many arguments the method takes (this
may be zero). It pops these arguments off the operand stack. Then it searches
the list of  static methods defined by the class, locating the method
<i xmlns="">methodname</i> with a descriptor <i xmlns="">descriptor</i>. <br></br>Once the method has been located, invokestatic calls the method.
First, if the method is marked as synchronized, the monitor associated
with the class object for the method's class is entered. Next, a new stack
frame structure is established on the call stack. Then the arguments for the
method (which were popped off the current method's operand stack) are placed in
local variables of the new stack frame structure. arg1 is stored in local
variable 0, arg2 is stored in local variable 1 and so on. Finally, execution
continues at the first instruction in the bytecode of the new method. <br></br>Methods marked as native are handled slightly differently. For native
methods, the runtime system locates the platform-specific code for the method,
loading it and linking it into the JVM if necessary. Then the native method
code is executed with the arguments that were popped from the operand stack.
The exact mechanism used to invoke native methods is implementation-specific.<br></br>When the method called by invokestatic returns, any single (or double)
word return result is placed on the operand stack of the current
method. If the invoked method was marked as synchronized, the monitor
associated with the class named in &lt;method-spec&gt; is exited. Execution
continues at the instruction that follows invokestatic in the
bytecode.</dd><dt>Exceptions</dt><dd>StackOverflowError - no more space in callstack for a new stack frame</dd><dt>See also</dt><dd><a href="ref-invokevirtual.html">invokevirtual</a> <a href="ref-.html"></a> <a href="ref-invokespecial.html">invokespecial</a> <a href="ref-.html"></a> <a href="ref-invokeinterface.html">invokeinterface</a> </dd><dt>Stack</dt><dd><table xmlns="">
<tr>
<td>
<b>Before </b>
</td>
<td><b>After</b></td></tr>
<tr>
<td>argN</td>
<td>[result]</td></tr>
<tr>
<td>...</td>
<td>...</td></tr>
<tr>
<td>arg3</td>
<td>...</td></tr>
<tr>
<td>arg2</td>
<td>...</td></tr>
<tr>
<td>arg1</td>
<td>...</td></tr>
</table></dd><dt>Bytecode</dt><dd><table xmlns="">
<tr>
<td>
<b> Type </b>
</td>
<td><b>Description</b></td></tr>
<tr>
<td>
u1 
</td>
<td>invokestatic
opcode = 0xB8 (184)
</td></tr>
<tr>
<td>
u2 
</td>
<td>index</td></tr>
</table></dd></dl></body></html>